home *** CD-ROM | disk | FTP | other *** search
/ Multimedia Jumpstart / Multimedia Microsoft Jumpstart Version 1.1a (Microsoft).BIN / develpmt / examples / infobrws / src / mciutils.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-09-03  |  7.9 KB  |  311 lines

  1. //     (C) Copyright Microsoft Corp. 1991.  All rights reserved.
  2. //
  3. //     You have a royalty-free right to use, modify, reproduce and 
  4. //     distribute the Sample Files (and/or any modified version) in 
  5. //     any way you find useful, provided that you agree that 
  6. //     Microsoft has no warranty obligations or liability for any 
  7. //     Sample Application Files which are modified. 
  8.  
  9.  
  10. /****************************************************************************
  11.  
  12.     MODULE    : MCIUTILS.C
  13.  
  14.     PURPOSE   : This module contains helper functions which work specifically with the functions contained
  15.                 in the MCI module.
  16.  
  17.     FUNCTIONS :  
  18.                 SeekAllToStart
  19.                 StopAllWaveFiles
  20.                 HideAllWindows
  21.                 FreeDevices
  22.                 AllDone
  23.  
  24.  
  25.     COMMENTS  : 
  26.  
  27.     HISTORY   :
  28.  
  29. ****************************************************************************/
  30.  
  31. #include "windows.h"
  32. #include <stdlib.h>
  33. #include "playvfw.h"
  34. #include "proto.h"
  35. #include "mmsystem.h"
  36. #include <digitalv.h>
  37. #include <stdio.h>
  38. #include <time.h>
  39.  
  40. /****************************************************************************
  41.  
  42.     FUNCTION    : SeekAllToStart()
  43.  
  44.     PURPOSE   :   This function takes all the AVI files and positions them at the begining.
  45.     
  46.     COMMENTS  : 
  47.  
  48.     HISTORY   : Created by Steven Molstad 8/7/93
  49.  
  50. ****************************************************************************/ 
  51.  
  52. BOOL FAR PASCAL SeekAllToStart()
  53. {
  54.  
  55.            SeekVFWToStart(lpDevice1->wDeviceID);
  56.            lpDevice1->bVideoPlaying=FALSE;
  57.            SeekVFWToStart(lpDevice2->wDeviceID);
  58.            lpDevice2->bVideoPlaying=FALSE;
  59.            SeekVFWToStart(lpDevice3->wDeviceID);
  60.            lpDevice3->bVideoPlaying=FALSE;
  61.            SeekVFWToStart(lpDevice4->wDeviceID);
  62.            lpDevice4->bVideoPlaying=FALSE;
  63.            SeekVFWToStart(lpDevice5->wDeviceID);
  64.            lpDevice5->bVideoPlaying=FALSE;
  65.            SeekVFWToStart(lpDevice6->wDeviceID);
  66.            lpDevice6->bVideoPlaying=FALSE;
  67.           
  68.  
  69. return TRUE;
  70. }       
  71.  
  72. /****************************************************************************
  73.  
  74.     FUNCTION  : StopAllWaveFiles()
  75.  
  76.     PURPOSE   : This function takes all wave files and stops them.  This is to ensure that when
  77.                 a wave file for a button starts playing all other wave files are stopped.
  78.     
  79.     COMMENTS  : 
  80.  
  81.     HISTORY   : Created by Steven Molstad 8/7/93
  82.  
  83. ****************************************************************************/ 
  84.  
  85. BOOL FAR PASCAL StopAllWaveFiles()
  86. {
  87.     
  88.             
  89.            StopWaveFile(lpDevice1->wAudioDeviceID);           
  90.            lpDevice1->bAudioPlaying=FALSE; 
  91.            
  92.             StopWaveFile(lpDevice2->wAudioDeviceID);           
  93.            lpDevice2->bAudioPlaying=FALSE; 
  94.            
  95.             StopWaveFile(lpDevice3->wAudioDeviceID);           
  96.            lpDevice3->bAudioPlaying=FALSE; 
  97.            
  98.            StopWaveFile(lpDevice4->wAudioDeviceID);           
  99.            lpDevice4->bAudioPlaying=FALSE; 
  100.            
  101.             StopWaveFile(lpDevice5->wAudioDeviceID);           
  102.            lpDevice5->bAudioPlaying=FALSE;   
  103.            
  104.             StopWaveFile(lpDevice6->wAudioDeviceID);           
  105.            lpDevice6->bAudioPlaying=FALSE; 
  106.            
  107.            
  108.          
  109. return TRUE;
  110. }
  111.  
  112. /****************************************************************************
  113.  
  114.     FUNCTION  : HideAllWindows()
  115.  
  116.     PURPOSE   : This function hides all video windows.  This function is used when we
  117.                 transition between pages.
  118.     
  119.     COMMENTS  : 
  120.  
  121.     HISTORY   : Created by Steven Molstad 8/1/93.
  122.  
  123. ****************************************************************************/ 
  124.  
  125. BOOL FAR PASCAL HideAllWindows()
  126. {
  127. ShowWindow( lpDevice1->hWnd, SW_HIDE );
  128. ShowWindow( lpDevice2->hWnd, SW_HIDE );
  129. ShowWindow( lpDevice3->hWnd, SW_HIDE );
  130. ShowWindow( lpDevice4->hWnd, SW_HIDE );
  131. ShowWindow( lpDevice5->hWnd, SW_HIDE );
  132. ShowWindow( lpDevice6->hWnd, SW_HIDE );
  133. ShowWindow( lpDevice7->hWnd, SW_HIDE );
  134. ShowWindow( lpDevice8->hWnd, SW_HIDE );
  135. return TRUE;
  136. }
  137.  
  138.  
  139. /****************************************************************************
  140.  
  141.     FUNCTION  : FreeDevices(HWND)
  142.  
  143.     PURPOSE   : This function frees all currently open devices.  This function is used to 
  144.                 ensure that all devices are closed at the end of the program.
  145.     
  146.     COMMENTS  : 
  147.  
  148.     HISTORY   : Created by Steven Molstad 8/1/93
  149.  
  150. ****************************************************************************/ 
  151.  
  152.  
  153. BOOL FAR PASCAL FreeDevices(hWnd)
  154. HANDLE hWnd;
  155. {
  156.  
  157. BOOL bReturn;
  158.  
  159. //MSG msg;
  160.  
  161.      
  162.  
  163.         
  164.         if (lpDevice1->wAudioDeviceID)
  165.               {
  166.               bReturn = CloseWaveFile(lpDevice1->wAudioDeviceID);
  167.               lpDevice1->wAudioDeviceID=0;
  168.               }
  169.  
  170.           
  171.         if (lpDevice2->wAudioDeviceID)
  172.               {
  173.  
  174.                bReturn = CloseWaveFile(lpDevice2->wAudioDeviceID);
  175.               lpDevice2->wAudioDeviceID=0;
  176.               }
  177.  
  178.         
  179.         if (lpDevice3->wAudioDeviceID)
  180.               {
  181.               bReturn = CloseWaveFile(lpDevice3->wAudioDeviceID);
  182.               lpDevice3->wAudioDeviceID=0;
  183.               }
  184.         
  185.         if (lpDevice4->wAudioDeviceID)
  186.               {
  187.                bReturn = CloseWaveFile(lpDevice4->wAudioDeviceID);
  188.               lpDevice4->wAudioDeviceID=0;
  189.               }
  190.  
  191.         
  192.  
  193.         if (lpDevice5->wAudioDeviceID)
  194.               {
  195.                bReturn = CloseWaveFile(lpDevice5->wAudioDeviceID);
  196.               lpDevice5->wAudioDeviceID=0;
  197.               }
  198.  
  199.         
  200.  
  201.         if (lpDevice6->wAudioDeviceID)
  202.               {
  203.                bReturn = CloseWaveFile(lpDevice6->wAudioDeviceID);
  204.               lpDevice6->wAudioDeviceID=0;
  205.               }
  206.     
  207.  
  208.         if (wGlobalAudioDeviceID)
  209.               {
  210.                bReturn = CloseWaveDevice(wGlobalAudioDeviceID);
  211.                wGlobalAudioDeviceID=0;
  212.               }
  213.  
  214.  
  215.     
  216.         if (lpDevice1->wDeviceID)
  217.               {
  218.                bReturn = CloseVFWFile(lpDevice1->wDeviceID);
  219.               lpDevice1->wDeviceID=0;
  220.               }
  221.  
  222.         
  223.         if (lpDevice2->wDeviceID)
  224.               {
  225.                bReturn = CloseVFWFile(lpDevice2->wDeviceID);
  226.                lpDevice2->wDeviceID=0;
  227.               }
  228.     
  229.  
  230.         if (lpDevice3->wDeviceID)
  231.               {
  232.                bReturn = CloseVFWFile(lpDevice3->wDeviceID);
  233.               lpDevice3->wDeviceID=0;
  234.               }
  235.  
  236.  
  237.         if (lpDevice4->wDeviceID)
  238.               {
  239.                bReturn = CloseVFWFile(lpDevice4->wDeviceID);
  240.                lpDevice4->wDeviceID=0;
  241.               }
  242.  
  243.     
  244.  
  245.         if (lpDevice5->wDeviceID)
  246.               {
  247.                bReturn = CloseVFWFile(lpDevice5->wDeviceID);
  248.                lpDevice5->wDeviceID=0;
  249.               }
  250.  
  251.         
  252.         if (lpDevice6->wDeviceID)
  253.               {
  254.                bReturn = CloseVFWFile(lpDevice6->wDeviceID);
  255.                lpDevice6->wDeviceID=0;
  256.               }  
  257.               
  258.          if (lpDevice9->wDeviceID)
  259.               {
  260.                bReturn = CloseVFWFile(lpDevice9->wDeviceID);
  261.                lpDevice9->wDeviceID=0;
  262.               }   
  263.               
  264.         
  265.         if (wGlobalDeviceID)
  266.               {
  267.                bReturn = CloseVFWDevice(hWnd,wGlobalDeviceID);
  268.                wGlobalDeviceID=0;
  269.               }
  270.  
  271.     
  272.  
  273.         /* grey menu item first */
  274.         /* enable second */
  275.     
  276. return TRUE;
  277.  
  278. }
  279.  
  280. /****************************************************************************
  281.  
  282.     FUNCTION    : AllDone()
  283.  
  284.     PURPOSE   : This program checks to see if a right button click has occured and a Video isn't still playing.
  285.                 If this case is true then return true.
  286.     
  287.     COMMENTS  : 
  288.  
  289.     HISTORY   : Created by Steven Molstad 8/1/93.
  290.  
  291. ****************************************************************************/ 
  292.  
  293. BOOL FAR PASCAL AllDone()
  294. {
  295.      if (lpDevice1->bRButtonClicked || lpDevice2->bRButtonClicked || lpDevice3->bRButtonClicked ||
  296.       lpDevice4->bRButtonClicked || lpDevice5->bRButtonClicked || lpDevice6->bRButtonClicked)
  297.       {
  298.       if (!lpDevice1->bVideoPlaying && !lpDevice2->bVideoPlaying && !lpDevice3->bVideoPlaying
  299.            && !lpDevice4->bVideoPlaying && !lpDevice5->bVideoPlaying && !lpDevice6->bVideoPlaying)
  300.            {
  301.            return TRUE;
  302.            }
  303.       else
  304.           return FALSE;
  305.       }
  306.      else
  307.       return FALSE;
  308.  
  309. }
  310.  
  311.